package com.hs.controller;

import com.hs.entity.UserSearchHistory;
import com.hs.service.UserSearchHistoryService;
import com.hs.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("usersearchhistory")
public class UserSearchHistoryController {
    @Autowired
    private UserSearchHistoryService userSearchHistoryService;
    @DeleteMapping("{id}")
    public R deleteusersearchhistoryById(@PathVariable("id") Integer id) {
        int i = userSearchHistoryService.deleteById(id);
        if (i > 0) {
            return R.ok("操作成功");
        }else{
            return R.fail("操作失败");
        }
    }
    @PostMapping("add")
    public R addusersearchhistory(@RequestBody UserSearchHistory userSearchHistory) {
        int i = userSearchHistoryService.insertUserSearchHistory(userSearchHistory);
        if (i > 0) {
            return R.ok("操作成功");
        }else{
            return R.fail("操作失败");
        }
    }
    @PutMapping("update")
    public R updateusersearchhistory(@RequestBody UserSearchHistory userSearchHistory) {
        int i = userSearchHistoryService.updaueUserSearchHistory(userSearchHistory);
        if (i > 0) {
            return R.ok("操作成功");
        }else{
            return R.fail("操作失败");
        }
    }
    @GetMapping("{id}")
    public R getusersearchhistoryById(@PathVariable("id") Integer id) {
        UserSearchHistory uu = userSearchHistoryService.getUserSearchHistoryById(id);
        return R.ok(uu);
    }
}
